<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html"
	template="/templates/template-tabela.xhtml">

	<ui:define name="title">
		<p:outputLabel value="#{label['categoria.titulo']}" styleClass="header-page" />
	</ui:define>

	<ui:define name="tabela">

		<p:dataTable id="dataTable" value="#{categoriaMB.listModel}" var="item" rows="10" paginator="true"
			paginatorPosition="bottom" emptyMessage="#{label['sistema.tabela.emptymessage']}" lazy="true">

			<p:column headerText="#{label['categoria.nome']}">
				<p:outputLabel value="#{item.nome}" />
			</p:column>

			<p:column headerText="#{label['sistema.tabela.acoes']}" width="70">

				<p:commandButton icon="ui-icon-pencil" title="#{label['sistema.botao.editar']}" process="@this"
					update="@form:panel_dialog" actionListener="#{categoriaMB.prepararEditar(item)}">
				</p:commandButton>

				<p:commandButton icon="ui-icon-close" title="#{label['sistema.botao.excluir']}"
					actionListener="#{categoriaMB.executarExcluir(item)}" process="@this" update="dataTable">
					<p:confirm />
				</p:commandButton>

			</p:column>

		</p:dataTable>

	</ui:define>

	<ui:define name="comandos">
		<p:commandButton value="#{label['sistema.botao.incluir']}" title="#{label['sistema.botao.incluir']}"
			oncomplete="PF('dialogCadastro').show()" process="@this" update="panel_dialog">
			<f:setPropertyActionListener target="#{categoriaMB.modelCad}" value="#{null}" />
		</p:commandButton>
	</ui:define>

	<ui:define name="custom-dialogs">

		<p:dialog id="dialogCadastro" header="#{label['sistema.dialog.cadastro.titulo']}" widgetVar="dialogCadastro"
			width="900" modal="true" closable="false" resizable="false">

			<p:panelGrid id="panel_dialog">

				<p:row>
					<p:column>
						<p:outputLabel value="#{label['categoria.nome']}" for="categoria_nome" />
					</p:column>
					<p:column>
						<p:inputText id="categoria_nome" value="#{categoriaMB.modelCad.nome}" required="true" size="50" maxlength="60" />
					</p:column>
				</p:row>

			</p:panelGrid>

			<f:facet name="footer">
				<p:commandButton value="#{label['sistema.botao.salvar']}" title="#{label['sistema.botao.salvar']}"
					actionListener="#{categoriaMB.executarSalvar()}" process="dialogCadastro" update="panel_dialog dataTable" />
				<p:commandButton value="#{label['sistema.botao.cancelar']}" title="#{label['sistema.botao.cancelar']}"
					onclick="PF('dialogCadastro').hide()" immediate="true">
					<f:setPropertyActionListener target="#{categoriaMB.modelCad}" value="#{null}" />
				</p:commandButton>
			</f:facet>
		</p:dialog>

	</ui:define>

</ui:composition>